﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="HisaabDataTemplateSelector.cs" company="Concept Architecture">
//   (c) 2010 Muhammad Umer Farooq
// </copyright>
// <summary>
//   Defines the <seealso cref="Hisaab.Windows.Client.HisaabDataTemplateSelector" /> type.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Hisaab.Windows.Client
{
    using System.Windows;
    using System.Windows.Controls;
    using ViewModel;

    /// <summary>
    /// Defines the <seealso cref="Hisaab.Windows.Client.HisaabDataTemplateSelector"/> type.
    /// </summary>
    public class HisaabDataTemplateSelector : DataTemplateSelector
    {
        /// <summary>
        /// When overridden in a derived class, returns a <see cref="T:System.Windows.DataTemplate"/> based on custom logic.
        /// </summary>
        /// <param name="item">The data object for which to select the template.</param>
        /// <param name="container">The data-bound object.</param>
        /// <returns>
        /// Returns a <see cref="T:System.Windows.DataTemplate"/> or null. The default value is null.
        /// </returns>
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item is LoginViewModel)
            {
                return Application.Current.FindResource("loginViewModel") as DataTemplate;
            }

            if (item is TagEditorViewModel)
            {
                return Application.Current.FindResource("tagEditorViewModel") as DataTemplate;
            }

            if (item is TagSummaryViewModel)
            {
                return Application.Current.FindResource("tagSummaryViewModel") as DataTemplate;
            }

            if (item is TransactionViewModel)
            {
                return Application.Current.FindResource("transactionViewModel") as DataTemplate;
            }

            if (item is AccountSummaryViewModel)
            {
                return Application.Current.FindResource("accountSummaryViewModel") as DataTemplate;
            }

            if (item is VehicleEditorViewModel)
            {
                return Application.Current.FindResource("vehicleEditorViewModel") as DataTemplate;
            }

            if (item is VehicleTransactionViewModel)
            {
                return Application.Current.FindResource("vehicleTransactionViewModel") as DataTemplate;
            }

            if (item is RelateTransactionViewModel)
            {
                return Application.Current.FindResource("relateTransactionViewModel") as DataTemplate;
            }

            if (item is BackupViewModel)
            {
                return Application.Current.FindResource("backupViewModel") as DataTemplate;
            }

            if (item is DashboardViewModel)
            {
                return Application.Current.FindResource("dashboardViewModel") as DataTemplate;
            }

            return base.SelectTemplate(item, container);
        }
    }
}